try{
	protocol= window.location.protocol;host = window.location.host;window._exurl=protocol+"//"+host;
	_.templateSettings= {  
		    "evaluate": /{([\s\S]+?)}/g,  
		    "interpolate": /{=([\s\S]+?)}/g,  
		    "escape": /{-([\s\S]+?)}/g  
};
$(document).ready(function(){
	$("body").addClass("K-stylesheet-default");
	var _i=0;
	for(var k in _jstemplates){
		_jstemplates[k](K[k].installation);
		_i++;
	}
	K.Info.installed=true;
	if(_i>0){K.Tool.log(_i+" toolkits installed.  K.Tool.getVersion()→"+K.Tool.getVersion());}
	else{K.Tool.log("K.Tool.getVersion()→"+K.Tool.getVersion());}
});
}catch(e){console.log("ts-error");};
window.K=window.K||{"URL":{"defaultTemplates":""}};
window._jstemplates=window._jstemplates||{};
K=$.extend(K,{
	"Tool":{
		"install":function(){
			K.Tool.log("The method [K.Tool.install] has been abolished");
			return K.Tool;
		},
		"log":function(str){console.log("K-Log: "+str);},
		"getDomPos":function($dom){
			 var pos={"top":0, "left":0},obj=$dom[0];
	         if (obj.offsetParent){
	           while(obj.offsetParent){
	             pos.top+=obj.offsetTop;
	             pos.left+=obj.offsetLeft;
	             obj=obj.offsetParent;
	           }
	         }else if(obj.x){
	           pos.left+=obj.x;
	         }else if(obj.y){
	           pos.top+=obj.y;
	         }
	         return {"x":pos.left,"y":pos.top};
		},"done":function(fn){
			if(typeof(fn)=="function")fn();
			return K.Tool;
		},"setURL":function(option){
			$.extend(K.URL,option);
		},"getVersion":function(){
			return K.Info.version;
		},"copy":function(domOrText){
			var t="";
			if(typeof(domOrText)=="string"){
				t=domOrText;
			}else{
				t=$(domOrText).text();
			}
			clipboard.copy(t);
		},"getFormJSON":function($f){
			var $f=$($f),rst={};
			$f.find("input").each(function(){
				var $i=$(this),_name=$i.attr("name")||"",_type=($i.attr("type")||"").toLowerCase();
				if($.trim(_name).length>0){
					switch(_type){
					case "select":
						rst[_name]=$i.children("option:selected").attr("value");
						break;
					case "radio":
						rst[_name]=$f.find("input[name='"+_name+"']:checked").val();
						break;
					default:
						rst[_name]=$i.val();
					}
				}
			});
			return rst;
		},"setData":function(dom,key,value){
			var kobj="__K.js.obj";
			if(typeof(value)!="string"){
				$(dom).data("data-"+key,value);
				$(dom).attr("data-"+key,kobj);
			}else{$(dom).attr("data-"+key,value);}
			return dom;
		},"getData":function(dom,key){
			var kobj="__K.js.obj";
			if(key){
				var v=$(dom).attr("data-"+key);
				if(v==kobj){
					return $(dom).data("data-"+key);
				}else{
					return v;
				}
			}else{
				var obj={};
				for(var i=0;i<$(dom)[0].attributes.length;i++){
					var k=$(dom)[0].attributes[i].name,
						v=$(dom)[0].attributes[i].value;
					if(k.length<=5||k.substring(0,5)!="data-")continue;
					if(v==kobj){
						obj[k.replace("data-","")]=$(dom).data(k);
					}else{
						obj[k.replace("data-","")]=v;
					}
				}
				return obj;
			}
		},"deleteData":function(dom,key){
			if(key){
				$(dom).removeData("data-"+key);
				$(dom).removeAttr("data-"+key);
			}else{
				for(var i=$(dom)[0].attributes.length-1;i>0;i--){
					var k=$(dom)[0].attributes[i].name,
						v=$(dom)[0].attributes[i].value;
					if(k.length<=5||k.substring(0,5)!="data-")continue;
					$(dom).removeData(k);
					$(dom).removeAttr(k);
				}
			}
			return dom;
		},"domPrint":function(dom,name){
			html2canvas($(dom)[0], {
		         onrendered: function (canvas) {
		             var imgData = canvas.toDataURL();
		           var _fixType = function(type) {
		              type = type.toLowerCase().replace(/jpg/i, 'jpeg');
		              var r = type.match(/png|jpeg|bmp|gif/)[0];
		              return 'image/' + r;
		          };
		          imgData = imgData.replace(_fixType("png"),'image/octet-stream');
		          var saveFile = function(data, filename){
		    var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
		    save_link.href = data;
		    save_link.download =filename;
		   
		    var event = document.createEvent('MouseEvents');
		    event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
		    save_link.dispatchEvent(event);
		};
		saveFile(imgData,name+".png");
		           }
		   });
		}
	},
	"Templates":{},
	"Installations":[],
	"Installations2":[],
	"LeftMenu":{
		"View":null,
		"template":{"name":"default","url":"template.html"},
		"installation":function(){
			K.LeftMenu.View=Backbone.View.extend({
			    "tagName":"div",
			    "className":"el-wrapper",
			    "template":_.template($("#_template>#t_leftmenu").text()),
			    "dataURL":false,
			    "data":false,
			    "events":{"onclick":function(){}},
			    "wrapper":null,
			    "setData":function(data_url){
			    	if(typeof(data_url)=="string")this.dataURL=data_url;
			    	else{this.data=data_url;}
			    	return this;
			    },"setURL":function(url){
			    	this.dataURL=url;
			    	return this;
			    },
			    "to":function($dom,showArrow){
			    	this.wrapper=$dom;
			    	this.$el.empty();
			    	this.events=$.extend({},this.events);
			    	if(this.data){
			    		this.render(this.data);
			    		$dom.append(this.$el);
			    		this.activate(showArrow);
			    	}else{
			    		$.ajax({"url":this.dataURL||K.URL.leftMenu,"dataType":"json","data":{"_":$.now()},
			    			    "dom":$dom,"_this":this}).done(function(json){
							this._this.render(json);
							this.dom.append(this._this.$el);
							this._this.activate(showArrow);
						}).fail(function(e1,e2,e3){
							K.Tool.log(e2);
						});
			    	}
			    	return this;
			    },"activate":function(showArrow){
			    	var menu=this,$menu=this.$el;
			    	$menu.off("click");
			    	$menu.on("click",function(event){event.stopPropagation();});
			    	$menu.find(".menu-lv1>li").each(function(){
			    		$(this).off("click");
						$(this).on("click",function(){
							$(this).siblings().removeClass("active");
							$(this).addClass("active");
						});
						$(this).unbind("hover");
						$(this).hover(function(event){
							if($(this).siblings(".active").length>0){
								$(this).siblings(".active").removeClass("active");
							}
						},function(){});
					});
					$menu.find(".menu-lv2>li:not('.leaf')").each(function(){
						$(this).off("click");
						$(this).on("click",function(){
							$(this).toggleClass("active");
							if($(this).hasClass("active")){
								$(this).siblings().removeClass("active");
							}
						});
					});
					$menu.find(".menu-lv2").css("left",this.wrapper.width()+"px");
					if(typeof(showArrow)=="string"&&showArrow.length>1&&showArrow.charAt(0)=="#"){
						$menu.find(".itemv1-arrow").each(function(){$(this).css("background-color",showArrow);});
					}
					$menu.find(".menu-lv2>.leaf,.menu-lv3>.leaf").each(function(){$(this).off("click");});
					$menu.find(".leaf").each(function(){
						$(this).on("click",function(menu,$leaf,showArrow){
							return function(event){
								event.stopPropagation();
								menu.$el.find(".leaf").removeClass("active");
								$leaf.addClass("active");
								var $li1=$leaf.parent().hasClass("menu-lv1")?$leaf:menu.$el.find(".menu-lv1").children("li:has('.leaf.active')");
								if(!$li1.hasClass("static")){$li1.addClass("static");}
								if(!$li1.hasClass("active")){$li1.addClass("active");}
								$li1.siblings().removeClass("static").removeClass("active");
								if(showArrow){
									menu.$el.find(".itemv1-arrow").hide();
									menu.$el.find(".static>.itemv1-arrow").show();
								}
								var arr=[],
							  	  getTxt=function($dom){
								  	arr.push($dom.attr("data-id")+"→"+$.trim($dom.children("nobr").text()));
								  	if(!$dom.parent().hasClass("menu-lv1")){
								  		$dom=$dom.parent().closest("li");
								  		getTxt($dom);
								  	}else{
								  		$dom=$dom.parent().closest("li");
								  		arr.push($dom.attr("data-id")+"→"+$.trim($dom.children("nobr").text()));
								  	}
					  	    	 };
							  getTxt($leaf);
							  arr.reverse();
							  if(arr.length>1)arr.shift();
								menu.events.onclick($leaf,arr);
							};
						}(menu,$(this),showArrow));
					});
					$("body").on("click",function(menu){
						return function(){
							menu.$el.find(".menu-lv1>.active").removeClass("active");
						};
					}(menu));
			    },"click":function(fn){
			    	if(typeof(fn)=="function"){this.events.onclick=fn;}
			    	return this;
			    },
			    "render":function(json){  
			        this.$el.html(this.template(json));
			        return this.$el;
			     }
			});
		},
		"init":function($dom,color){
			$dom.empty();
			var menu=new K.LeftMenu.View();
			if(!K.URL.leftMenu){
				menu.setData("../../json/emp/leftmenu.json");
			}
			menu.to($dom,color);
			return menu;
		}
	},"Catalog":{
		"View":null,
		"template":{"name":"default","url":"template.html"},
		"installation":function(){
			K.Catalog.View=Backbone.View.extend({
			    "tagName":"div",
			    "className":"el-wrapper",
			    "template":_.template($("#_template>#t_catalog").text()),
			    "data":false,
				"dataURL":false,
				"wrapper":null,
			    "render":function(json){  
			        this.$el.html(this.template(this.data||json));
			        return this.$el;
			     },"setData":function(data_url){
			    	if(typeof(data_url)=="string")this.dataURL=data_url;
			    	else{this.data=data_url;}
			    	return this;
			     },"to":function($dom){
			    	this.wrapper=$dom;
			    	this.$el.empty();
			    	if(this.data){
			    		this.render(this.data);
			    	}else{
			    		this.render({"title":"EPC Soulutions","levels":[]});
			    	}
			    	$dom.append(this.$el);
			    	return this;
			    }
			});
		},"init":function($dom){
			$dom.empty();
			var cata=new K.Catalog.View();
			cata.to($dom);
			return cata;
		}
		
	},"Profile":{
		"View":null,
		"template":{"name":"default","url":"template.html"},
		"installation":function(){
			K.Profile.View=Backbone.View.extend({
			    "tagName":"div",
			    "className":"el-wrapper",
			    "template":_.template($("#_template>#t_profile").text()),
			    "data":false,
				"dataURL":false,
				"wrapper":null,
				"events":{"onclick":function(){}},
			    "render":function(json){  
			        this.$el.html(this.template(this.data||json));
			        this.$el.css("text-align","center");
			        return this.$el;
			     },"setData":function(data_url){
			    	if(typeof(data_url)=="string")this.dataURL=data_url;
			    	else{this.data=data_url;}
			    	return this;
			     },"setURL":function(url){
				    	this.dataURL=url;
				    	return this;
				 },"to":function($dom){
			    	 if(this.data){
			    		this.render(this.data);
			    		$dom.append(this.$el);
			    		this.activate();
			    	 }else{
			    		$.ajax({"url":this.dataURL||K.URL.profile,"dataType":"json","data":{"_":$.now()},
			    				"dom":$dom,"_this":this}).done(function(json){
							this._this.render(json);
							this.dom.append(this._this.$el);
							this._this.activate();
						}).fail(function(e1,e2,e3){
							K.Tool.log(e2);
						});
			    	}
			    	 return this;
			    },"activate":function(){
			    	var $menu=this.$el.find(".profile-menu"),pf=this;
			    	this.$el.find(".user-profile-name").on("click",function($menu){
			    		return function(event){
			    			event.stopPropagation();
			    			if(!$menu.is(":visible")){
			    				$menu.show();
			    			}
			    		};
			    	}($menu));
			    	$menu.on("click",function(event){
			    		event.stopPropagation();
			    	});
			    	$menu.find("li").each(function(){
			    		$(this).on("click",function($item,pf){
			    			return function(){
			    				pf.events.onclick($item);
			    			};
			    		}($(this),pf));
			    	});
			    	$("body").on("click",function($menu){
			    		return function(){
			    			$menu.hide();
			    		};
			    	}($menu));
			    },"click":function(fn){
			    	if(typeof(fn)=="function"){this.events.onclick=fn;}
			    	return this;
			    }
			});
		},"init":function($dom){
			$dom.empty();
			var pf=new K.Profile.View();
			pf.to($dom);
			return pf;
		}
	},"HeaderBar":{
		"View":null,
		"template":{"name":"default","url":"template.html"},
		"installation":function(){
			K.HeaderBar.View=Backbone.View.extend({
			    "tagName":"div",
			    "className":"el-wrapper bg-c1",
			    "template":_.template($("#_template>#t_headerbar").text()),
			    "data":false,
				"dataURL":false,
				"wrapper":null,
				"events":{"onclick":function(){},"onsearch":function(){}},
				"logoBGC":false,
				"logoTip":false,
			    "render":function(json){  
			        this.$el.html(this.template(this.data||json));
			        this.$el.css("height","100%").css("min-height","50px");
			        return this.$el;
			     },"setData":function(data_url){
			    	if(typeof(data_url)=="string")this.dataURL=data_url;
			    	else{this.data=data_url;}
			    	return this;
			     },"setURL":function(url){
			    	this.dataURL=url;
			    	return this;
				 },"to":function($dom){
			    	 if(this.data){
			    		this.render(this.data);
			    		$dom.append(this.$el);
			    		this.activate();
			    	 }else
			    	{
			    		$.ajax({"url":this.dataURL||K.URL.headerBar,"dataType":"json","data":{"_":$.now()},
			    				"dom":$dom,"_this":this}).done(function(json){
							this._this.render(json);
							this.dom.append(this._this.$el);
							this._this.activate();
						}).fail(function(e1,e2,e3){
							K.Tool.log(e2);
						});
			    	}
			    	 return this;
			    },"activate":function(){
			    	if(this.logoBGC)this.$el.find(".top-logo").css("background-color",this.logoBGC);
			    	if(this.logoTip)this.$el.find(".top-logo").attr("title",this.logoTip);
			    	var $keywords=this.$el.find(".search-txt"),$submit=this.$el.find(".search-submit");
			    	$submit.off("mousedown");
			    	$submit.on("mousedown",function(_this,$keywords){
			    		return function(){
			    			if($.trim($keywords.val()).length>0)
			    			_this.events.onsearch($.trim($keywords.val()));
			    		};
			    	}(this,$keywords));
			    	$keywords.off("keyup");
			    	$keywords.on("keyup",function(_this,$keywords){
			    		return function(event){
			    			if(event.keyCode==13&&$.trim($keywords.val()).length>0){
			    				_this.events.onsearch($.trim($keywords.val()));
			    			}
			    		};
			    	}(this,$keywords));
			    	return this;
			    },"click":function(fn){
			    	if(typeof(fn)=="function"){this.events.onclick=fn;}
			    	return this;
			    },"search":function(fn){
			    	if(typeof(fn)=="function"){this.events.onsearch=fn;}
			    	return this;
			    },"setLogoBGColor":function(color){
			    	this.logoBGC=color;
			    	this.activate();
			    	return this;
			    },"setLogoTip":function(tip){
			    	this.logoTip=tip;
			    	this.activate();
			    	return this;
			    }
			});
		},"init":function($dom){
			$dom.empty();
			var hb=new K.HeaderBar.View();
			hb.to($dom);
			return hb;
		}
	},
	"Info":{
		"installed":false,
		"developVersion":false,
		"version":"0.1.1"
	}
});